<template>
  <el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
    <form-edit ref="form" :form-data="form" @fetch-data="fetchData" />
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import FormEdit from './FormEdit'
export default {
  name: 'RepairDesktopEdit',
  components: { FormEdit },
  data() {
    return {
      form: {},
      title: '',
      dialogFormVisible: false,
    }
  },
  created() { },
  methods: {
    showEdit(row) {
      if (!row) {
        this.title = '添加'
      } else {
        this.title = '编辑'
        this.form = Object.assign({}, row)
      }
      this.dialogFormVisible = true
    },
    close() {
      this.$refs['form'].close()
      this.dialogFormVisible = false
    },
    save() {
      this.$refs['form'].save()
    },
    fetchData() {
      this.$emit('fetch-data')
      this.dialogFormVisible = false
    }
  },
}
</script>
